package com.hjq.fcloud.other

import com.hjq.fcloud.R
import com.hjq.fcloud.app.AppApplication
import com.hjq.fcloud.bean.DtlsBean
import com.hjq.fcloud.widget.HorizontalScrollItem
import java.util.ArrayList

object MaterialsDetailHandler {

    fun buildMaterialsDetailList(dtls: ArrayList<DtlsBean>?): ArrayList<ArrayList<HorizontalScrollItem>> {
        var list = ArrayList<ArrayList<HorizontalScrollItem>>()
        list.add(buildTitle())

        addContent(dtls, list)

        return list
    }

    private fun addContent(
        dtls: ArrayList<DtlsBean>?,
        list: ArrayList<ArrayList<HorizontalScrollItem>>
    ) {
        dtls?.forEach {
            var item = ArrayList<HorizontalScrollItem>()
            item.add(HorizontalScrollItem(it.mat_id))

            item.add(HorizontalScrollItem(it.mat.type_name))

            item.add(HorizontalScrollItem(it.mat.name))

            item.add(HorizontalScrollItem(it.mat.spec))

            item.add(HorizontalScrollItem(it.mat.unit))

            item.add(HorizontalScrollItem(it.price))

            item.add(HorizontalScrollItem(it.fnc_dtl?.plan_amount.toString()))

            item.add(HorizontalScrollItem(it.amount.toString()))

            item.add(HorizontalScrollItem(it.money.toString()))

            item.add(HorizontalScrollItem(it.fnc_dtl?.store_amount.toString()))

            item.add(HorizontalScrollItem(it.fnc_dtl?.store_money.toString()))

            list?.add(item)
        }
    }

    private fun buildTitle(): ArrayList<HorizontalScrollItem> {
        var resources = AppApplication.mContext!!.resources
        var item = ArrayList<HorizontalScrollItem>()
        item.add(HorizontalScrollItem("序号", resources.getDimensionPixelSize(R.dimen.dp_64)))

        item.add(HorizontalScrollItem("材料类型", resources.getDimensionPixelSize(R.dimen.dp_144)))

        item.add(HorizontalScrollItem("材料名称", resources.getDimensionPixelSize(R.dimen.dp_144)))

        item.add(HorizontalScrollItem("规格", resources.getDimensionPixelSize(R.dimen.dp_172)))

        item.add(HorizontalScrollItem("单位", resources.getDimensionPixelSize(R.dimen.dp_80)))

        item.add(HorizontalScrollItem("采购单价", resources.getDimensionPixelSize(R.dimen.dp_120)))

        item.add(HorizontalScrollItem("计划数量", resources.getDimensionPixelSize(R.dimen.dp_120)))

        item.add(HorizontalScrollItem("入库数量", resources.getDimensionPixelSize(R.dimen.dp_120)))

        item.add(HorizontalScrollItem("入库合价", resources.getDimensionPixelSize(R.dimen.dp_120)))

        item.add(
            HorizontalScrollItem(
                "已入库数量",
                resources.getDimensionPixelSize(R.dimen.dp_120)
            )
        )

        item.add(
            HorizontalScrollItem(
                "已入库合价",
                resources.getDimensionPixelSize(R.dimen.dp_120)
            )
        )

        return item
    }

}